import 'package:flutter/material.dart';
import 'package:flutter_soundmagus/page/menu/page_menu.dart';
import 'package:flutter_soundmagus/util/util.dart';
import 'package:get/get.dart';

///页面基类
class PageBase extends StatefulWidget {
  const PageBase({Key? key}) : super(key: key);

  @override
  PageBaseState createState() => PageBaseState<PageBase>();
}

class PageBaseState<T extends PageBase> extends State<T> {
  Widget buildBody(BuildContext context) {
    return Container();
  }

  bool menuHidden = true;

  Color backgroundColor = Colors.black;

  @override
  Widget build(BuildContext context) {
    Widget child = menuHidden
        ? buildBody(context)
        : Stack(
            children: [
              buildBody(context),
              _buildMenuBar(),
            ],
          );
    return child;
    return Scaffold(
      backgroundColor: backgroundColor,
      body: child,
      // resizeToAvoidBottomInset: false,
    );
  }

  _buildMenuBar() {
    return Container(
      // height: 60,
      child: Row(
        children: [
          _buildMenu(left: true),
          Spacer(),
          _buildMenu(left: false),
        ],
      ),
    );
  }

  Widget _buildMenu({bool left = true}) {
    return GestureDetector(
      onTap: () {
        Get.dialog(
            PageMenu(
              left: left,
            ),
            useSafeArea: false);
      },
      child: Image.asset(
        left ? 'icon_menu_left'.img : 'icon_menu_right'.img,
        width: 71.w,
      ),
    );
  }
}
